package Database;
import java.sql.*;
import Logging.Log;

public class Connector {

	/** Uses DriverManager.  */
	  static Connection getConnection() 
	  {
		  //See your driver documentation for the proper format of this string :
		  String DB_CONN_STRING = "jdbc:sqlite:vydavky.db";
		  //Provided by your driver documentation. In this case, a MySql driver is used : 
		  String DRIVER_CLASS_NAME = "org.sqlite.JDBC";
			
		  Connection result = null;
		  try 
		  {
			  Class.forName(DRIVER_CLASS_NAME).newInstance();
		  }
		  catch (Exception ex)
		  {
			  Log.log("Check classpath. Cannot load db driver: " + DRIVER_CLASS_NAME);
			  System.exit(0);
		  }
		  
		  try 
		  {
			  result = DriverManager.getConnection(DB_CONN_STRING);
		  }
		  catch (SQLException e)
		  {
			  Log.log( "Driver loaded, but cannot connect to db: " + DB_CONN_STRING);
			  System.exit(0);
		  }
		  return result;
	  }
}
